<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>
<template>
    <div>
        <Form :label-width="80" >
            <Input v-model="name"  placeholder="根据用户名查找" style="width: 200px;margin-right: 3px;"></Input>
            <Input v-model="phone" placeholder="根据手机号查找" style="width: 200px"></Input>
            <FormItem label="矿机等级" style="width: 300px;display: inline-block" >
                <Select v-model="star" style="margin-right: 3px;" >
                    <Option value="0">全部</Option>
                    <Option value="V1">V1</Option>
                    <Option value="V2">V2</Option>
                    <Option value="V3">V3</Option>
                    <Option value="V4">V4</Option>
                    <Option value="V5">V5</Option>
                    <Option value="V0">V0</Option>
                    <Option value="NL">NL</Option>
                </Select>
            </FormItem>

            <div style="float: right">
            <Button type="info" style="float: right;margin-right: 5px" @click="load">搜索</Button>
            </div>
        </Form>
        <Table :loading="loading" refs="table1"  :data="Message" :columns="columnsList"></Table>
        <Page :total="pageNum" :page-size="pageSize"  style="text-align: center;margin-top: 15px;" show-total   show-elevator show-sizer @on-change="pageChange"></Page>


    </div>
</template>
<script>
    import $http from '../../utils/axiosWrap'
    import canEditTable from '../tables/components/canEditTable.vue'
    export default {
        data() {
            return {
                loading: true,
                Message:[],
                admin:true,
                star:"",
                columnsList: [
                    {
                        title: '序号',
                        width: 80,
                        render: (h, params) => {
                            return  params.index + (this.initPage- 1) * this.pageSize + 1
                        }
                    },
                    {
                        title: '用户名',
                        align: 'center',
                        key: 'userName',
                        editable: true
                    },
                    {
                        title: '手机号',
                        align: 'center',
                        key: 'phone',
                        editable: true
                    },
                    {
                        title: '购买矿机等级',
                        align: 'center',
                        key: 'oreLevelName',
                        editable: true
                    },
                    {
                        title: '矿机本金数量',
                        align: 'center',
                        key: 'totlePrice',
                        editable: true
                    },
                    {
                        title: '购买时间',
                        align: 'center',
                        key: 'createTime',
                        editable: true
                    }
                ],
                name: '',
                phone: '',
                pageNum:1,
                pageSize:10,
                initPage:1
            }
        },
        created: function () {
            this.load()
        },
        methods: {
            load (){
                let _this = this
                let params = new URLSearchParams()
                params.append('userName',_this.name)
                params.append('phone',_this.phone)
                params.append('page',_this.initPage)
                if(_this.star == '0'){
                    _this.star = ''
                }
                params.append('oreLevelName',_this.star)
                $http.post('/oreAllModules/getUserBuyOreLogInfoPage',params).then(function (res) {
                    if(res.suc){
                        console.log(res)
                    _this.Message = res.result.list
                    _this.pageNum = res.result.totalRow
                    _this.loading = false
                }else{
                    if(res.msg == "请先登录"){
                        _this.$Message.error('请重新登录！');
                    }else{
                        _this.$Message.error(res.msg);
                    }
                }
                })
            },
            pageChange(index){
                this.initPage = index
                this.loading = true
                this.load ()
            }
        }
    }
</script>
<style>
</style>

